package com.kingsoft.dc.khaos.metadata

/**
  * Created by chengguangqing on 2019/5/31.
  */
/**
  * _id：组件的id
  * _name：组件的名称
  * _engine：组件的引擎
  * _clazz：组件的clazz
  * _clazzType:组件的类型
  * _moduleConf：组件的完整配置信息w
  * _dependence：组件之间的依赖 | 组件的入度
  * _degreeOut：组件的出度
  */

class ModuleCommon {
  private var _id: String = _
  private var _name: String = _
  private var _engine: String = _
  private var _clazz: String = _
  private var _clazzType: String = _
  private var _moduleConf: String = _
  private var _dependence: List[String] = _ //入度
  private var _dataDependency: List[Dependency] = _
  private var _degreeOut: List[String] = _ //出度
  private var _degreeOutTarget:List[Dependency] = _


  def this(id: String,
           name: String,
           engine: String,
           clazz: String,
           clazzType: String,
           moduleConf: String,
           dispatchTime: String,
           dependence: List[String],
           dataDependency: List[Dependency],
           degreeOut: List[String],
           degreeOutTarget:List[Dependency]
          ) {
    this()
    _id = id
    _name = name
    _engine = engine
    _clazz = clazz
    _clazzType = clazzType
    _moduleConf = moduleConf
    _dependence = dependence
    _dataDependency = dataDependency
    _degreeOut = degreeOut
    _degreeOutTarget = degreeOutTarget
  }

  //如果没有出度信息，则使用此构造方法
  def this(id: String,
           name: String,
           engine: String,
           clazz: String,
           clazzType: String,
           moduleConf: String,
           dispatchTime: String,
           dependence: List[String],
           dataDependency: List[Dependency]) {
    this(id, name, engine, clazz, clazzType, moduleConf, dispatchTime, dependence, dataDependency, List[String](),List[Dependency]())
  }

  //如果没有出度 && 依赖信息，则使用此构造方法
  def this(id: String,
           name: String,
           engine: String,
           clazz: String,
           clazzType: String,
           moduleConf: String,
           dispatchTime: String) {
    this(id, name, engine, clazz, clazzType, moduleConf, dispatchTime, List[String](), List[Dependency](), List[String](),List[Dependency]())
  }


  /*添加获取属性的方法*/
  def id = _id

  def name = _name

  def engine = _engine

  def clazz = _clazz

  def clazzType = _clazzType

  def moduleConf = _moduleConf

  def degreeOutTarget = _degreeOutTarget

  def dependence = _dependence

  def degreeOut = _degreeOut

  def dataDependence = _dataDependency

  //重写toString方法
  override def toString: String = {
    s"id : $id, name: $name, engine: $engine, clazz: $clazz, clazzType: $clazzType" +
      s"moduleConf: $moduleConf, dependence: $dependence, degreeOut: $degreeOut," +
      s"dataDependency : $dataDependence, degreeOutTarget: $degreeOutTarget"
  }
}

//可能还需要修改
object ModuleCommon {
  def apply(
             id: String,
             name: String,
             engine: String,
             clazz: String,
             clazzType: String,
             moduleConf: String,
             dispatchTime: String): ModuleCommon = {
    new ModuleCommon(id, name, engine, clazz, clazzType, moduleConf, dispatchTime)
  }
}
